// getCookie 函数
function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i <ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}

// 获取某个 Cookie
getCookie('index_new_key')

// 增加 cookie
document.cookie = encodeURIComponent('username') + '=' +
				  encodeURIComponent('cover');

// 增加 cookie, 还有其他参数
document.cookie = encodeURIComponent('username') + '=' +
    encodeURIComponent('cover') +
    '; domain=ke.qq.com' +
    '; expires=' + new Date('2018-1-1');

// 删除 cookie
document.cookie = encodeURIComponent('username') + '=' +
    encodeURIComponent('cover') +
    '; domain=ke.qq.com' +
    '; expires=' + new Date(0);